package org.zjt.spark

import org.apache.spark.{SparkConf, SparkContext}

/**
  * Created by Administrator on 2017/4/30.
  */
object SortWordCount extends App{

  val conf = new SparkConf().setAppName("WordCount").setMaster("local")
  val sc = new SparkContext(conf)
  sc.textFile("test.txt").flatMap(_.split(",")).map((_,1)).reduceByKey(_+_).sortBy(_._2,false).collect().foreach(println)
  sc.stop();

}
